package com.ydtech.controller;

import com.ydtech.common.exception.DescribeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class HelloController {
    Logger logger = LoggerFactory.getLogger(HelloController.class);

    //调用可以用http://localhost:8080/hello?name=yaox
    @GetMapping({"/", "/hello"})
    public String hello888(Model model,
                           @RequestParam(value = "name", required = false, defaultValue = "World") String name)
            throws DescribeException {
        logger.info("进入了index");
        logger.error("这是测试的");
        model.addAttribute("name", name);

//        if (true) {
//            throw new Exception("errorrrrrrrrr");
//        }

//        if(true){
//            throw new DescribeException("这是可描述的错误", 20020);
//        }
        return "hello";
    }
}